import request from '@/utils/request'


// 获取单品满赠活动列表
export function listDedicated (query) {
    return request({
        url: '/store/promotion/dedicated',
        method: 'get',
        params: query
    })
}
// 新增单品满赠活动
export function addDedicated (data) {
    return request({
        url: '/store/promotion/dedicated',
        method: 'POST',
        data: data
    })
}
// 修改单品满赠活动
export function updateDedicated (id, data) {
    return request({
        url: '/store/promotion/dedicated/' + id,
        method: 'put',
        data: data
    })
}

//  获取单品满赠活动规则列表
export function getGoodsActivityRuleList (promotionGoodsId) {
    return request({
        url: `/store/promotion/dedicated/${promotionGoodsId}/rules`,
        method: 'get',
    })
}
//  获取 赠品 /dev-api/store/promotion/dedicated/rules/{ruleId}/gifts
export function getGoodsGiveList (ruleId) {
    return request({
        url: `/store/promotion/dedicated/rules/${ruleId}/gifts`,
        method: 'get',
    })
}

// 增 /dev-api/store/promotion/dedicated/{promotionGoodsId}/rules
export function addGoodsActivityRule (freeShippingId, promotionGoodsId, data) {
    return request({
        url: `/store/promotion/dedicated/${freeShippingId}/${promotionGoodsId}/rules`,
        method: 'post',
        data: data
    })
}
// 删
export function delGoodsActivityRule (fullReductionId, promotionGoodsId, id) {
    return request({
        url: `/store/promotion/dedicated/${fullReductionId}/${promotionGoodsId}/rules/${id}`,
        method: 'delete',
    })
}
// 改
export function updGoodsActivityRule (fullReductionId, promotionGoodsId, id, data) {
    return request({
        url: `/store/promotion/dedicated/${fullReductionId}/${promotionGoodsId}/rules/${id}`,
        method: 'put',
        data: data,
    })
}


// 所有商品列表
export function allGoodsGiveList (params) {
    return request({
        url: `/goods/goods`,
        method: 'get',
        params: params
    })
}

//  新增单品买赠活动规则赠品
export function addGoodsGive (ruleId, data) {
    return request({
        url: `/store/promotion/dedicated/rules/${ruleId}/gifts`,
        method: 'post',
        data: data
    })
}

//  修改单品买赠活动规则赠品
export function updGoodsGive (ruleId, id, data) {
    return request({
        url: `/store/promotion/dedicated/rules/${ruleId}/gifts/${id}`,
        method: 'put',
        data: data
    })
}

//  删除单品买赠活动规则赠品
export function delGoodsGive (ruleId, id) {
    return request({
        url: `/store/promotion/dedicated/rules/${ruleId}/gifts/${id}`,
        method: 'delete',
    })
}

// 关闭 活动 
export function closeActivity (id) {
    return request({
        url: `/store/promotion/dedicated/${id}/close`,
        method: 'delete',
    })
}